<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增车辆维修')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-repair-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">车牌号：</label>
            <div class="col-sm-8">
                <select class="form-control noselect2 selectpicker" id="cCarld">
                </select>
            </div>
        </div>
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label is-required">申请人头像：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="cPicture" class="form-control" type="text" required>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label is-required">申请人：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="cPeople" class="form-control" type="text" required>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label is-required">申请人部门：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="cDepa" class="form-control" type="text" required>-->
<!--            </div>-->
<!--        </div>-->

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">车辆维修原因：</label>
            <div class="col-sm-8">
                <input name="cRemark" class="form-control" type="text" id="cRemark" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">车辆维修金额：</label>
            <div class="col-sm-8">
                <input name="cMoney" class="form-control" type="text" id="cMoney" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">车辆维修照片：</label>
            <div class="col-sm-8">
                <input name="cData" class="form-control" type="file" id="cData" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">车辆维修时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="cTime" class="form-control" placeholder="yyyy-MM-dd" id="cTime" type="text" required>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script type="text/javascript">
    var prefix = ctx + "ruoyi/repair"
    var prefixlike=ctx+"ruoyi/manage"
    $("#form-repair-add").validate({
        focusCleanup: true
    });
    uplike();
    function submitHandler() {
        if ($.validate.form()) {
            uploadFile();
        }
    }
    function uplike(){
        $.ajax({
            url: prefixlike + "/lists",
            type: "post",
            dataType:"json",
            data: {},
            success: function(data){
                if(data.length>0){
                    //value='"+data[i].tName+","+data[i].tName+"'
                    for(i in data){
                        $("#cCarld").append("<option>"+data[i].cCarid+"</option>")
                    }
                }else{
                    $("#cCarld").append("<option>暂无数据</option>")
                }
            }
        });
    }
    function uploadFile() {
        var formData = new FormData();
        if ($('#cData')[0].files[0] == null) {
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
        var options = $("#cCarld option:selected");
        var cCarld = options.val();
        formData.append('cCarld',cCarld);
        formData.append('cRemark', $("#cRemark").val());
        formData.append('cTime', $("#cTime").val());
        formData.append('cMoney', $("#cMoney").val());
        formData.append('file', $('#cData')[0].files[0]);
        $.ajax({
            url: prefix + "/add/",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function(result) {
                $.operate.successCallback(result);
            }
        });
    }
    $("input[name='cTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>